package com.sentiment.db;

import org.bson.Document;

import com.sentiment.obj.PatentInfo;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
/**
 * 专利数据库PatentInfo
 * @author Ma
 *
 */
public class PatentInfoDB {

	private MongoClient mongoClient;
	private MongoDatabase mongodb;
	private MongoCollection<Document> mongoCollection;
	public PatentInfoDB() {

		mongoClient = new MongoClient();

		mongodb = mongoClient.getDatabase("detection");

		mongoCollection = mongodb.getCollection("PatentInfo");
	}
	public void DBClose() {
		mongoClient.close();
	}
	public void cleanAll() {
		// 清理掉PatentInfo中原有的数据
		mongoCollection.drop();
	}
	public void saveData(PatentInfo info){
		Document Abstract = info.getAbstract();
		Document doc = new Document("PatentTitle", info.getPatentTitle()).append("PatentType", info.getPatentType()).append("PatentNum", info.getPatentNum())
				.append("ApplicationDate", info.getApplicationDate()).append("DisclosureDate", info.getDisclosureDate()).append("PatentTypegreen", info.getPatentTypegreen())
				.append("DisclosureNum", info.getDisclosureNum()).append("ClassificationMainNum", info.getClassificationMainNum())
				.append("ClassificationNum", info.getClassificationNum()).append("Applicant", info.getApplicant())
				.append("Inventor", info.getInventor()).append("ApplicantAdd", info.getApplicantAdd())
				.append("Agency", info.getAgency()).append("Agent", info.getAgent())
				.append("CityNum", info.getCityNum()).append("LegalStatus", info.getLegalStatus())
				.append("Abstract", Abstract).append("PrincipalClaim", info.getPrincipalClaim());

		mongoCollection.insertOne(doc);
	}
	
	String aaa;
	
}
